<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
	<title>商城-登录注册</title>
	<link rel="stylesheet" type="text/css" href="../../css/base.css" />
	<style type="text/css">
		body {
			background-color: #fff;
		}

		#footer {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			padding-bottom: 0.2rem;
		}

		.Third_party span {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 0.85rem;
			margin-bottom: 0.2rem;
		}

		.Third_party span img {
			width: 0.45rem;
			height: 0.45rem;
		}

		.register_footer {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 0.12rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(179, 179, 179, 1);
			line-height: 0.17rem;
		}

		.register_footer img {
			width: 0.17rem;
			height: 0.17rem;
			margin-right: 0.05rem;
			vertical-align: center;
		}
		.agreement span {
			color: #005A93;
		}
	</style>
</head>

<body>
	<div class="" id="app">

		<!-- 底部栏 -->
		<div id="footer">
			<footer class="ming-bg-white">
				<div class="foot_info">
					<div>
						<div class="Third_party" v-if="now_time>end_time">
							<span>
								<img v-if="qq_show" tapmode onclick="login_q()"    src="../../image/btn/btn-qq.png"/>
								<img v-if="wechat_show" tapmode onclick="login_w()"    src="../../image/btn/btn-weixin.png" />
								<img v-if="weibo_show" tapmode onclick="login_sina()" src="../../image/btn/btn-weibo.png" />
							</span>
						</div>
						<!-- <div class="register_footer">
							<img onclick='showDL_yonghu()' :src="!DLselect?'../../image/btn/unselected.png':'../../image/btn/selected.png'" alt="">
							<div class="agreement">
								登录注册需同意 <span tapmode onclick="open_win_page('用户协议')">用户协议</span> 和 <span tapmode onclick="open_win_page('隐私协议')">隐私协议</span>
							</div>
							<span v-else style="display: inline-block;width: 0.8rem;height: 0.56rem;margin-right: 0.2rem;"><img src="../../image/btn/selected.png" alt=""></span>登录注册需同意
						</div> -->

					</div>
				</div>
			</footer>
		</div>

	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script>
	var vm = new Vue({
		el: "#app",
		data: {
			flag: true,
			DLselect: false,
			ZCselect: false,
			now_time:Date.parse(new Date()) / 1000,
			weibo_show:false,
			qq_show:false,
			wechat_show:false,
			end_time:''
		},
		methods:{
			authThird: function() {
				var obj_qq = api.require('QQPlus');
				obj_qq.installed(function(ret, err) {
					if (ret.status) {} else {
						vm.qq_show = false;
					}
				});
				var obj_wx = api.require('wxPlus');
				obj_wx.isInstalled(function(ret, err) {
					if (ret.installed) {} else {
						vm.wechat_show = false;
					}
				});
				var sinaWeiBo = api.require('weiboPlus');
				sinaWeiBo.isInstalled(
					function(ret) {
						if (ret.status) {} else {
							vm.weibo_show = false;
						}
					}
				);
				get_data('api/login/get_end_time', {
				}, function(ret) {
					// alert(JSON.stringify(ret))
					vm.end_time = ret.data;
				});
			},
		}
	})
	apiready = function() {
		api.openFrame({
			name: 'login_f',
			url: './login_f.html',
			bounces: false,
			rect: {
				x: 0,
				y: 0,
				w: api.winWidth,
				h: api.winHeight - $api.dom('#footer').offsetHeight
			},
			vScrollBarEnabled: false,
			bgColor: 'rgba(0,0,0,0)'
		})

		vm.authThird()
	};
	/*-------------------------------------------*/


	// 引入 QQ/微信/新浪微博 的分享功能
	function login_q() {
		login_qq(function(ret) {
			var qq = api.require('QQPlus');
			var openid = ret.openId;
			qq.getUserInfo(function(ret, err) {
				if (ret.status) {
					var info = ret.info
					login_bind(openid, 'qq', info.nickname)
				} else {}
			});
		}, function(error) {
			vm.qq_show = false;
		})
	}

	function login_w() {
		login_wechat(function(ret) {
			var wx = api.require('wxPlus');
			var openid = ret.openId;
			wx.getUserInfo({
				accessToken: ret.accessToken,
				openId: openid
			}, function(ret, err) {
				if (ret.status) {
					login_bind(openid, 'wx', ret.nickname)
						//						alert(JSON.stringify(ret));
				} else {
					alert(err.code);
				}
			});
		}, function(error) {
			vm.wechat_show = false;
		})
	}

	function login_sina() {
		login_wb(function(ret) {
			var openid = ret.userId;
			var token = ret.token;
			login_bind(openid, 'sina', openid)
			return;
			//alert(JSON.stringify(ret))
			var weibo = api.require('weiboPlus');
			weibo.getUserInfo({
				token: token,
				userId: openid
			}, function(ret, err) {
				alert(token + '/' + openid)
				if (ret.status) {
					//alert(JSON.stringify(ret));
					login_bind(openid, 'sina', info.nickname)
				} else {
					alert(JSON.stringify(err));
				}
			});
		}, function(error) {
			vm.weibo_show = false;
		})
	}

	//sina 微博登录的flag
	function login_bind(openId, flag, name) {
		get_data('api/login/isBindMobile', {
			openid: openId,
			flag: flag
		}, function(ret) {
			if (ret.status == '1') {
				$api.setStorage('token', ret.data.token)
				save_userinfo_new(ret)
				send_event('logined')
				setTimeout(function() {
					close_win()
				}, 300);
			} else {
				toast(ret.msg)
				$api.setStorage('bindinfo', {
					openid: openId,
					flag: flag,
					name: name
				})
				open_win('bind', 'bind.html', false)
				setTimeout(function() {
					close_win()
				}, 1000);
			}
		})
	}

	function return_index() {
		api.closeFrameGroup({
			name: 'IndexGroup'
		});
		send_event('return_index', {
			index: 0
		})
		closeToRoot();
	}

	//登录/注册 隐私勾选
	function showDL_yonghu() {
		if (vm.DLselect == true) {
			vm.DLselect = false;
			send_event('is_check', {
				is_check: true
			})
		} else {
			vm.DLselect = true;
			send_event('is_check', {
				is_check: true
			})
		}
	}

	function showZC_yonghu() {
		if (vm.DLselect == true) {
			vm.DLselect = false;
			send_event('is_check', {
				is_check: true
			})
		} else {
			vm.DLselect = true;
			send_event('is_check', {
				is_check: true
			})
		}
	}
</script>

</html>
